ComponentOne Basic Library for WPF and Silverlight
Setting Values
WPF and Silverlight Edition Basic Library > NumericBox > NumericBox Elements > Setting Values

There are four properties to set to control the currently selected number (Value), how much that number changes when the Up or Down button is clicked at run-time (Increment), and the range of numbers that can be selected (Minimum and Maximum).

The Value property determines the currently selected number. By default the C1NumericBox control starts with its Value set to 0 but you can customize this number at design time, in XAML, and in code.

In XAML

To set the Value property add Value="123" to the <c1:C1NumericBox> tag so that it appears similar to the following:

XAML
Copy Code
<c1:C1NumericBox Name="C1NumericBox1" Value="123" />

In Code

To set the Value property add the following code to your project:

Visual Basic
Copy Code
C1NumericBox1.Value = 123

 

C#
Copy Code
c1NumericBox1.Value = 123;

At Design Time

To set the Value property at run time, complete the following steps:

  1. Click the C1NumericBox control once to select it.
  2. Navigate to the Properties window, and enter a number, for example "123", in the text box next to the Value property.

This will set the Value property to the number you chose.

The Increment property determines by how much the Value property changes when the Up or Down button is clicked at run time. By default the C1NumericBox control starts with its Increment set to 1 but you can customize this number at design time, in XAML, and in code.

In XAML

To set the Increment property to 20 add Increment="20" to the <c1:C1NumericBox> tag so that it appears similar to the following:

XAML
Copy Code
<c1:C1NumericBox Name="C1NumericBox1" Increment="20" />

In Code

To set the Increment property to 20 add the following code to your project:

Visual Basic
Copy Code
C1NumericBox1.Increment = 20

 

C#
Copy Code
c1NumericBox1.Increment = 20;

At Design Time

To set the Increment property at run time, complete the following steps:

  1. Click the C1NumericBox control once to select it.
  2. Navigate to the Properties window, and enter a number, for example "20", in the text box next to the Increment property.

This will set the Increment property to the number you chose.

You can use the Minimum and Maximum properties to set a numeric range that users are limited to at run time. If the Minimum and Maximum properties are set, users will not be able to pick a number smaller than the Minimum or larger than the Maximum.

In XAML

To set the Minimum and Maximum in XAML add Maximum="500" Minimum="-500" to the <c1:C1NumericBox> tag so that it appears similar to the following:

XAML
Copy Code
<c1:C1NumericBox Name="C1NumericBox1" Maximum="500" Minimum="-500" />

In Code

To set the Minimum and Maximum add the following code to your project:

Visual Basic
Copy Code
C1NumericBox1.Minimum = -500
C1NumericBox1.Maximum = 500

 

C#
Copy Code
c1NumericBox1.Minimum = -500;
c1NumericBox1.Maximum = 500;

At Design Time

To set the Minimum and Maximum at run time, complete the following steps:

  1. Click the C1NumericBox control once to select it.
  2. Navigate to the Properties window, and enter a number, for example 500, next to the Maximum property.
  3. In the Properties window, enter a number, for example -500, next to the Minimum property.

This will set Minimum and Maximum values.